execfile('v4/base.py')

class RaiseScoreF(Base):
    def __init__(self):
        self.bar_count_default = 50
        self.end_date_str = '20250831'  # 如果需要可以取消注释
        # self.start_date_str = '2025-06-16'  # 如果需要可以取消注释

    '''
        打分策略：
            1、raise_score：当日涨幅打分
            2、turnover_score：60日成交金额打分
            3、r_d1_score：raise_score乘以turnover_score
            4、r_d10_score：10日涨幅打分
            5、final_score：总分
    
    '''
    def mark_vol_raise_score(self,df):
        df['d_turnover_max'] = df.groupby('code')['turnover'].transform(lambda x: x.rolling(window=60, min_periods=1).max())
        df.loc[:,'max_pct'] = df.code.apply(lambda x: 10 if (x.startswith('0') or x.startswith('60')) else 20)
        df['raise_score'] = df['r1']/df['max_pct']
        df['turnover_score'] = df['turnover']/df['d_turnover_max']
        df['r_d1_score'] = df['raise_score']* df['turnover_score']
        df.loc[:,'d10_max'] =  df.code.apply(lambda x: 100 if (x.startswith('0') or x.startswith('60')) else 150)
        df['r_d10_score'] = 1 - df['r10']/df['d10_max']
        df['final_score'] = df['r_d1_score']* df['r_d10_score']
        return df